//
//  tabbarVC.m
//  充电桩
//
//  Created by 李超杰 on 17/4/13.
//  Copyright © 2017年 李超杰. All rights reserved.
//

#import "tabbarVC.h"
#import "accountBookVC.h"
#import "chartVC.h"
#import "keepAccountsVC.h"
#import "findVC.h"
#import "myVC.h"

@interface tabbarVC ()

@end

@implementation tabbarVC
//- (void)viewWillLayoutSubviews{
//    CGRect tabFrame = self.tabBar.frame;
////    tabFrame.size.height = 49;
//    tabFrame.origin.y = self.view.frame.size.height - 49;
//    self.tabBar.frame = tabFrame;
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    accountBookVC *accountBook = [[accountBookVC alloc]init];
    
    UINavigationController *navAccountBook = [[UINavigationController alloc]initWithRootViewController:accountBook];
    [self controller:navAccountBook title:@"账本" tabbarImage:@"homepage_grey" tabbarselectImage:@"homepage_green"];
    
    
    chartVC *chart = [[chartVC alloc]init];
    UINavigationController *navChart= [[UINavigationController alloc]initWithRootViewController:chart];
    [self controller:navChart title:@"图表" tabbarImage:@"community" tabbarselectImage:@"communityIcon"];
    
    keepAccountsVC *keepAccounts = [[keepAccountsVC alloc]init];
    UINavigationController *navKeepAccounts = [[UINavigationController alloc]initWithRootViewController:keepAccounts];
    [self controller:navKeepAccounts title:@"记账" tabbarImage:@"community" tabbarselectImage:@"communityIcon"];
    
    findVC *find = [[findVC alloc]init];
    UINavigationController *navFind = [[UINavigationController alloc]initWithRootViewController:find];
    [self controller:navFind title:@"发现" tabbarImage:@"map" tabbarselectImage:@"map_icon"];
    
    myVC *my = [[myVC alloc]init];
    UINavigationController *navMy = [[UINavigationController alloc]initWithRootViewController:my];
    [self controller:navMy title:@"我的" tabbarImage:@"my" tabbarselectImage:@"myIcon"];
    
    
//    //修改状态栏颜色
//    [[UIApplication sharedApplication] setStatusBarHidden:NO];
//    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    self.viewControllers = @[navAccountBook,navChart,navKeepAccounts,navFind,navMy];
    
//    [self.navigationController.tabBarItem setTitlePositionAdjustment:UIOffsetMake(12, 12)];
    [[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, -3)];

    
    
}

-(void)controller:(UIViewController *)controller title:(NSString *)title tabbarImage:(NSString *)image tabbarselectImage:(NSString *)selectImage{
    
    controller.title = title;
    controller.tabBarItem.image = [UIImage imageNamed:image];
    UIImage *homeImage = [UIImage imageNamed:selectImage];
    //设置tabbar选中的照片（不被系统默认渲染，显示图片原本的颜色）
    homeImage = [homeImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [controller.tabBarItem setSelectedImage:homeImage];
    
    // 设置 tabbarItem 选中状态下的文字颜色(不被系统默认渲染,显示文字自定义颜色)
    
    NSDictionary *dictHome = [NSDictionary dictionaryWithObject:[UIColor colorWithHexString:@"#00b9a3"] forKey:NSForegroundColorAttributeName];
    
    [controller.tabBarItem setTitleTextAttributes:dictHome forState:UIControlStateSelected];
    
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
